package com.zy.reflect.adv_proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * The type My invocation hanlder.
 *
 * @Author Gong
 * @Description
 * @dATE 2021 /12/21 11:25
 */
public class MyInvocationHanlder implements InvocationHandler {
    Object object;//被代理对象的声明
    public void setObject(Object obj){
        this.object=obj;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        HumanUtil human=new HumanUtil();
        human.methodOne();//方法1
        Object returnVal=method.invoke(object, args);
        human.methodTwo();//方法2
        return returnVal;
    }
}
